/*
 * @Author: qin
 * @Date:   2019-04-28
 * +----------------------------------------------------------------------
 * | admin [ 后台管理系统公共配置信息 ]
 * +----------------------------------------------------------------------
 */
layui.define(['jquery','configureCom','configure','sessionFun', 'matchDict'], function (exports) {
    var $ = layui.jquery;
    var configureCom = layui.configureCom;
    var configure = layui.configure;
    var sessionFun = layui.sessionFun;
    var matchDict = layui.matchDict;
    var indexEchartFun = {
        // 各市强条统计
        cityQtInit: function () {
            var cityQt = echarts.init(document.getElementById('cityQt'));
            /*configureCom.postDataAjax(configure).then(function (res) {

            });*/
            var cityQtOption = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                calculable: false,
                series: [
                    {
                        name: '访问来源',
                        type: 'pie',
                        selectedMode: 'single',
                        radius: [0, 40],

                        // for funnel
                        x: '20%',
                        width: '40%',
                        funnelAlign: 'right',
                        max: 1548,

                        itemStyle: {
                            normal: {
                                label: {
                                    position: 'inner'
                                },
                                labelLine: {
                                    show: false
                                }
                            }
                        },
                        data: [
                            {value: 335, name: '强条数'}
                        ]
                    },
                    {
                        name: '访问来源',
                        type: 'pie',
                        radius: [50, 70],

                        // for funnel
                        x: '60%',
                        width: '35%',
                        funnelAlign: 'left',
                        max: 1048,

                        data: [
                            {value: 335, name: '百色市'},
                            {value: 310, name: '南宁市'},
                            {value: 234, name: '柳州市'},
                            {value: 135, name: '梧州市'},
                            {value: 1048, name: '北海市'},
                            {value: 251, name: '贵港市'}
                        ]
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            cityQt.setOption(cityQtOption);
        },
        //各专业强条统计
        specQtInit: function () {
            var specQt = echarts.init(document.getElementById('specQt'));
            var labelTop = {
                normal: {
                    label: {
                        show: false,
                        formatter: '{b}',
                        textStyle: {
                            baseline: 'middle'
                        },
                        position: ['10%', '30%']
                    },
                    labelLine: {
                        show: false
                    }
                }
            };
            var labelFromatter = {
                normal: {
                    label: {
                        formatter: function (params) {
                            return 100 - params.value + '%'
                        },
                        textStyle: {
                            baseline: 'middle',
                            fontSize: 10,
                            color: '#fdd100'
                        }
                    }
                }
            };
            var labelBottom = {
                normal: {
                    color: '#0f3c5c',
                    label: {
                        show: true,
                        position: 'center'
                    },
                    labelLine: {
                        show: false
                    }
                },
                emphasis: {
                    color: 'rgba(0,0,0,0)'
                }
            };
            var radius = [16, 20];
            var specQtOption = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                color: ['#3fecff'],
                calculable: false,
                series: [
                    {
                        type: 'pie',
                        center: ['10%', '15%'],
                        radius: radius,
                        x: '0%', // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 60, itemStyle: labelBottom},
                            {name: '轨道交通专业', value: 40, itemStyle: labelTop}
                        ]
                    }, {
                        type: 'pie',
                        center: ['60%', '15%'],
                        radius: radius,
                        x: '20%', // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 50, itemStyle: labelBottom},
                            {name: '勘察专业', value: 50, itemStyle: labelTop}
                        ]
                    }, {
                        type: 'pie',
                        center: ['10%', '50%'],
                        radius: radius,
                        x: '40%', // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 70, itemStyle: labelBottom},
                            {name: '暖通专业', value: 30, itemStyle: labelTop}
                        ]
                    },
                    {
                        type: 'pie',
                        center: ['60%', '50%'],
                        radius: radius,
                        x: '60%', // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 70, itemStyle: labelBottom},
                            {name: '给排水专业', value: 30, itemStyle: labelTop}
                        ]
                    }, {
                        type: 'pie',
                        center: ['10%', '85%'],
                        radius: radius,
                        x: '80%', // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 80, itemStyle: labelBottom},
                            {name: '结构专业', value: 20, itemStyle: labelTop}
                        ]
                    },
                    {
                        type: 'pie',
                        center: ['60%', '85%'],
                        radius: radius,
                        y: '55%',   // for funnel
                        x: '0%',    // for funnel
                        itemStyle: labelFromatter,
                        data: [
                            {name: 'other', value: 80, itemStyle: labelBottom},
                            {name: '建筑专业', value: 20, itemStyle: labelTop}
                        ]
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            specQt.setOption(specQtOption);
        },
        //城市投资统计
        cityTzCountInit: function () {
            var cityTzCount = echarts.init(document.getElementById('cityTzCount'));
            var cityTzCountOption = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                series: [
                    {
                        type: 'pie',
                        radius: [20, 40],
                        center: ['50%', '50%'],
                        roseType: 'area',
                        x: '50%',               // for funnel
                        max: 40,                // for funnel
                        sort: 'ascending',     // for funnel
                        data: [
                            {value: 10, name: '百色市'},
                            {value: 15, name: '梧州市'},
                            {value: 15, name: '北海市'},
                            {value: 10, name: '玉林市'},
                            {value: 20, name: '河池市'},
                            {value: 10, name: '贺州市'},
                            {value: 20, name: '贵港市'}
                        ]
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            cityTzCount.setOption(cityTzCountOption);
        },
        //全省各市项目审查业绩统计图
        cityYjInit: function () {
            var cityYj
            $('.cityYj').each(function (index, item) {
                cityYj = echarts.init(item);
                var cityYjOption = {
                    tooltip: {
                        trigger: 'axis'
                    },
                    grid: {
                        borderWidth: 0
                    },
                    xAxis: [
                        {
                            splitLine: {show: false},
                            splitArea: {show: false},//保留网格区域
                            type: 'category',
                            axisLabel: {
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            data: ['南宁市', '北海市', '钦州市', '柳州市', '贵港市', '防城港', '百色市', '来宾', '河池', '梧州市', '崇左', '贺州', '桂林', '玉林']
                        }
                    ],
                    color: ['#00c6ff'],
                    yAxis: [
                        {
                            min: 0,
                            splitNumber: 5,
                            position: 'left',
                            max: 2500,
                            axisLabel: {
                                show: true,
                                interval: 'auto',    // {number}
                                margin: 18,
                                formatter: '{value}',    // Template formatter!
                                textStyle: {
                                    color: '#fff',
                                    fontFamily: 'verdana',
                                    fontSize: 10,
                                    fontStyle: 'normal',
                                    fontWeight: 'bold'
                                }
                            },
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    color: ['#064866'],
                                    width: 1,
                                    type: 'solid'
                                }
                            },
                            splitArea: {show: false},//保留网格区域
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '',
                            type: 'bar',
                            barWidth: 15,//柱图宽度
                            itemStyle: {        //上方显示数值
                                normal: {
                                    label: {
                                        show: true, //开启显示
                                        position: 'top', //在上方显示
                                        textStyle: { //数值样式
                                            backgroundColor: '#A89463',
                                            borderRadius: [5, 5, 5, 5],
                                            color: 'white',
                                            fontSize: 16
                                        }
                                    }
                                }
                            },
                            data: [1000, 2000, 1800, 1500, 2100, 1652, 1000, 2000, 1800, 1500, 2100, 1652, 1800, 1500]
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                cityYj.setOption(cityYjOption);
            });
        },
        //全省建筑面积历年趋势图
        areaCountInit: function () {
            console.log(echarts)
            var areaCount = echarts.init(document.getElementById('areaCount'));
            var areaCountOption = {
                tooltip: {
                    trigger: 'axis'
                },
                grid: {
                    x: 55,
                    x2: 100,
                    borderWidth: 0
                },
                xAxis: [
                    {
                        splitLine: {show: false},
                        splitArea: {show: false},//保留网格区域
                        type: 'category',
                        axisLabel: {
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        data: ['2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019']
                    }
                ],
                color: ['#3fecff'],
                yAxis: [
                    {
                        min: 0,
                        splitNumber: 5,
                        position: 'left',
                        max: 2500,
                        axisLabel: {
                            show: true,
                            interval: 'auto',    // {number}
                            margin: 5,
                            formatter: '{value}',    // Template formatter!
                            textStyle: {
                                color: '#fff',
                                fontSize: 10,
                                fontStyle: 'normal'
                            }
                        },
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: ['#064866'],
                                width: 1,
                                type: 'solid'
                            }
                        },
                        splitArea: {show: false},//保留网格区域
                        type: 'value'
                    }, {
                        type: 'value',
                        name: '',
                        min: 0,
                        max: 100,
                        position: 'left',
                        interval: 10,
                        splitLine: {
                            show: true,
                            lineStyle: {
                                color: ['#064866'],
                                width: 1,
                                type: 'solid'
                            }
                        },
                        splitArea: {show: false},//保留网格区域
                        axisLabel: {
                            show: true,
                            interval: 'auto',    // {number}
                            margin: 10,
                            formatter: '{value} %',    // Template formatter!
                            textStyle: {
                                color: '#fff',
                                fontSize: 10,
                                fontStyle: 'normal'
                            }
                        }
                    }
                ],
                series: [
                    {
                        name: '',
                        type: 'bar',
                        barWidth: 15,//柱图宽度
                        data: [1000, 2000, 1800, 1500, 2100, 1652, 1000, 2000, 1800, 1500, 2100, 1652, 1800, 1500]
                    },
                    {
                        name: '',
                        type: 'line',
                        yAxisIndex: 1,    //这里要设置哪个y轴，默认是最左边的是0，然后1，2顺序来。
                        data: [75, 65, 85, 66, 45, 55, 56, 42, 78, 69, 70, 36, 42, 50, 65, 75, 80],
                        symbolSize: 3,
                        itemStyle: {
                            normal: {
                                color: "#fdd100"
                            }
                        }
                    }
                ]
            };
            // 使用刚指定的配置项和数据显示图表。
            areaCount.setOption(areaCountOption);
        }
    };
    exports('indexEchartFun', indexEchartFun);
});
